#/bin/bash


RUNNING_DIR=$(cd $(dirname $0);pwd)
echo $RUNNING_DIR
# deploy type can be hybrid, semi-hybrid, split
DEPLOYTYPE=${1:-hybrid}
export GS_PASSWORD='Gauss!23'
#export STANDBYHOSTS=127.0.0.1

export GAUSSHOME=/opt/openGauss
export PGDATA=/opt/data/openGauss/dn
export GAUSS_CM_DIR=/opt/data/openGauss/cm

# install use deploy type: hybrid 
function install() {
    export PRIMARYHOST="172.11.0.2"
    export STANDBYHOSTS="172.11.0.3,172.11.0.4"
    export PRIMARYNAME=db-opengauss-01
    export STANDBYNAMES=db-opengauss-02,db-opengauss-03
    install.sh
    #cat cluster.xml
}

# semi_hybrid_install use deploy type: semi-hybrid 
function semi_hybrid_install() {
    export PRIMARYHOST=172.11.0.4
    export STANDBYHOSTS="172.11.0.5,172.11.0.6"
    export PRIMARYNAME=db-opengauss-03
    export STANDBYNAMES=db-opengauss-04,db-opengauss-05
    export CMSHOSTS="172.11.0.2,172.11.0.3,172.11.0.4"
    export CMSNAMES=db-opengauss-01,db-opengauss-02,db-opengauss-03
}
function split_install() {
    export PRIMARYHOST=172.11.0.5
    export STANDBYHOSTS="172.11.0.6,172.11.0.7"
    export PRIMARYNAME=db-opengauss-04
    export STANDBYNAMES=db-opengauss-05,db-opengauss-06
    export CMSHOSTS="172.11.0.2,172.11.0.3,172.11.0.4"
    export CMSNAMES=db-opengauss-01,db-opengauss-02,db-opengauss-03
}

if [[ $DEPLOYTYPE == "hybrid" ]];then
    echo "Test deploy type: hybrid"
    install
elif [[ $DEPLOYTYPE == "semi-hybrid" ]];then
    echo "Test deploy type: semi-hybrid"
    semi_hybrid_install
else
    echo "Test deploy type: split"
    split_install
fi
./install.sh